﻿/*
 * Created by SharpDevelop.
 * User: Chris
 * Date: 5/7/2013
 * Time: 10:43 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.IO;
using Dither.Framework;

namespace Dither.Xna.Bindings.Project
{
	/// <summary>
	/// Description of XnaContentFileName.
	/// </summary>
	public class XnaContentFileName
	{
		public static readonly string[] AudioFiles = {
			".xap",
			".wav",
			".wma",
			".mp3"
		}; 
		
		public static readonly string[] TextureFiles = {
			".bmp",
			".jpg",
			".png",
			".tga",
			".dds"
		};
		
		public static readonly string[] ModelFiles = {
			".fbx",
			".x"
		};
		
		public static readonly string[] EffectFiles = {
			".fx"
		};
		
		public static readonly string[] FontFiles = {
			".spritefont"
		};
		
		public static readonly string[] XmlFiles = {
			".xml"
		};
		
		public static readonly string[] VideoFiles = {
			".wmv"
		};
		
		public static string[] ContentFiles;
		
		static XnaContentFileName()
		{
			ContentFiles = ExtendedEnvironment.CombineArrays(AudioFiles, TextureFiles, ModelFiles, EffectFiles, FontFiles, XmlFiles, VideoFiles);
		}
		
		public static bool IsContentFile(string fileName)
		{
			return CheckForExtensionInArray(ContentFiles, fileName);
		}
		
		public static bool IsAudioFile(string fileName)
		{
			return CheckForExtensionInArray(AudioFiles, fileName);
		}
		
		public static bool IsTextureFile(string fileName)
		{
			return CheckForExtensionInArray(TextureFiles, fileName);
		}
		
		public static bool IsModelFile(string fileName)
		{
			return CheckForExtensionInArray(ModelFiles, fileName);
		}
		
		public static bool IsEffectFile(string fileName)
		{
			return CheckForExtensionInArray(EffectFiles, fileName);
		}
		
		public static bool IsFontFile(string fileName)
		{
			return CheckForExtensionInArray(FontFiles, fileName);
		}
		
		public static bool IsXmlFile(string fileName)
		{
			return CheckForExtensionInArray(XmlFiles, fileName);
		}
		
		public static bool IsVideoFile(string fileName)
		{
			return CheckForExtensionInArray(VideoFiles, fileName);
		}
		
		static bool CheckForExtensionInArray(string[] extensions, string fileName)
		{			
			for (int i = 0; i < extensions.Length; i++) {
				if (String.Compare(Path.GetExtension(fileName), extensions[i], true) == 0)
				{
					return true;
				}
			}
			
			return false;
		}
	}
}
